﻿<%@ Page Language="C#" MasterPageFile="~/Hoso/MasterPage_Hoso.master" AutoEventWireup="true" CodeFile="QuanlyBaiviet.aspx.cs" Inherits="Hoso_QuanlyBaiviet" %>
<%@ Register TagPrefix="uc" TagName="Menu" Src="~/Hoso/QuantriMenu.ascx"%>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
       
       <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
   
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="638px" 
        AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" 
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True"
        DataSourceID="SqlDataSource1" GridLines="None" 
        ondatabound="RadGrid1_DataBound" onitemdeleted="RadGrid1_ItemDeleted" 
        oniteminserted="RadGrid1_ItemInserted" 
        onitemupdated="RadGrid1_ItemUpdated" Skin="Office2007" 
        onitemcommand="RadGrid1_ItemCommand" PageSize="5">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

<MasterTableView AutoGenerateColumns="False" DataKeyNames="mabaiviet" 
            DataSourceID="SqlDataSource1">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
      
     <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColum" FilterControlAltText="Filter EditCommandColumn column">
                    </telerik:GridEditCommandColumn>

         <telerik:GridHyperLinkColumn FooterText="HyperLinkColumn footer" DataTextFormatString="Link"
                        DataNavigateUrlFields="mabaiviet" UniqueName="mabaiviet" DataNavigateUrlFormatString="../Baiviet.aspx?mabv={0}"
                        DataTextField="mabaiviet">
                    </telerik:GridHyperLinkColumn>           

        <telerik:GridBoundColumn DataField="mabaiviet" DataType="System.Int32" 
            FilterControlAltText="Filter mabaiviet column" HeaderText="Mã bài viết" 
            ReadOnly="True" SortExpression="mabaiviet" UniqueName="mabaiviet">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="tenbaiviet" 
            FilterControlAltText="Filter tenbaiviet column" HeaderText="Tên bài viết" 
            SortExpression="tenbaiviet" UniqueName="tenbaiviet" >
        </telerik:GridBoundColumn>
        
        <telerik:GridBoundColumn DataField="noidung" 
            FilterControlAltText="Filter noidung column" HeaderText="Nội dung" 
            SortExpression="noidung" UniqueName="noidung">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="maphumuc" DataType="System.Int32" 
            FilterControlAltText="Filter maphumuc column" HeaderText="Mã phụ mục" 
            SortExpression="maphumuc" UniqueName="maphumuc">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="mathanhvien" DataType="System.Int32" 
            FilterControlAltText="Filter mathanhvien column" HeaderText="Mã thành viên" 
            SortExpression="mathanhvien" UniqueName="mathanhvien">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ngaylap" DataType="System.DateTime" 
            FilterControlAltText="Filter ngaylap column" HeaderText="Ngày lập" 
            SortExpression="ngaylap" UniqueName="ngaylap" DataFormatString="{0:MM/dd/yyyy}">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="matinhtrangbv" DataType="System.Int32" 
            FilterControlAltText="Filter matinhtrangbv column" HeaderText="Mã tình trạng" 
            SortExpression="matinhtrangbv" UniqueName="matinhtrangbv">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="listchat" 
            FilterControlAltText="Filter listchat column" HeaderText="Listchat" 
            SortExpression="listchat" UniqueName="listchat">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="xem" DataType="System.Int32" 
            FilterControlAltText="Filter xem column" HeaderText="Xem" SortExpression="xem" 
            UniqueName="xem">
        </telerik:GridBoundColumn>
        <telerik:GridButtonColumn ConfirmText="Delete this bài viết?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" />
                    </telerik:GridButtonColumn>
    </Columns>

<EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="mabaiviet" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Baiviet">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
<FormTemplate>             
 <table style="width: 80%">
        <tr>
            <td style="width: 562px">
                Tên bài viết</td>
            <td style="width: 250px">
                <asp:TextBox ID="txttenbaiviet" runat="server" Text='<%# Bind("tenbaiviet") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="nhập tên bv" ControlToValidate="txttenbaiviet"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                Nội dung</td>
            <td style="width: 250px">
                <asp:TextBox ID="txtnoidung" runat="server" Text='<%# Bind("noidung") %>'></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="nhập nội dung" ControlToValidate="txtnoidung"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                Tên phụ mục</td>
            <td style="width: 250px">
                <asp:DropDownList ID="dropmaphumuc" runat="server" Width="100px"  SelectedValue='<%# Bind("maphumuc") %>'
                                                DataTextField="tenphumuc" TabIndex="7" DataValueField="maphumuc" DataSourceID="SqlDataSource2"
                                                AppendDataBoundItems="True">
                <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                </asp:DropDownList>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="chọn phụ mục" ControlToValidate="dropmaphumuc"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                Tên thành viên</td>
            <td style="width: 250px">
                <asp:DropDownList ID="dropmathanhvien" runat="server" Width="100px"  SelectedValue='<%# Bind("mathanhvien") %>'
                                                DataTextField="tenthanhvien" TabIndex="7" DataValueField="mathanhvien" DataSourceID="SqlDataSource3"
                                                AppendDataBoundItems="True">
                <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                </asp:DropDownList>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="chọn thành viên" ControlToValidate="dropmathanhvien"></asp:RequiredFieldValidator>
            </td>
        </tr>
    
        <tr>
            <td style="width: 562px">
                Ngày lập</td>
            <td style="width: 250px">
            
                 <asp:TextBox ID="txtngaylap" runat="server" Text='<%#Bind("ngaylap","{0:MM/dd/yyyy}")%>'></asp:TextBox>
           <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="nhập ngày" ControlToValidate="txtngaylap"></asp:RequiredFieldValidator>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="nhập tháng ngày năm" Type="Date" Operator="DataTypeCheck" ControlToValidate="txtngaylap"></asp:CompareValidator>
            </td>
            <td>tháng/ngày/năm</td>
        </tr>
        <tr>
            <td style="width: 562px">
                Tên tình trạng bv</td>
            <td style="width: 250px">
                <asp:DropDownList ID="dropmatinhtrangbv" runat="server" Width="100px"  SelectedValue='<%# Bind("matinhtrangbv") %>'
                                                DataTextField="tentinhtrangbv" TabIndex="7" DataValueField="matinhtrangbv" DataSourceID="SqlDataSource4"
                                                AppendDataBoundItems="True">
                <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                </asp:DropDownList>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="chọn tình trạng" ControlToValidate="dropmatinhtrangbv"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                List chat</td>
            <td style="width: 250px">
                <asp:TextBox ID="txtlist" runat="server" Text='<%# Bind("listchat") %>'></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="nhập list chat" ControlToValidate="txtlist"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 562px">
                Xem</td>
            <td style="width: 250px">
                <asp:TextBox ID="txtxem" runat="server" Text='<%# Bind("xem") %>'></asp:TextBox>
                 <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="nhập xem" ControlToValidate="txtxem"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
         <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
        </tr>
        </table>
        </FormTemplate>
</EditFormSettings>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>
<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
   
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        DeleteCommand="DELETE FROM [BAIVIET] WHERE [mabaiviet] = @mabaiviet" 
        InsertCommand="INSERT INTO [BAIVIET] ([tenbaiviet], [noidung], [maphumuc], [mathanhvien], [ngaylap], [matinhtrangbv], [listchat], [xem]) VALUES (@tenbaiviet, @noidung, @maphumuc, @mathanhvien, @ngaylap, @matinhtrangbv, @listchat, @xem)" 
        SelectCommand="SELECT * FROM [BAIVIET]" 
        UpdateCommand="UPDATE [BAIVIET] SET [tenbaiviet] = @tenbaiviet, [noidung] = @noidung, [maphumuc] = @maphumuc, [mathanhvien] = @mathanhvien, [ngaylap] = @ngaylap, [matinhtrangbv] = @matinhtrangbv, [listchat] = @listchat, [xem] = @xem WHERE [mabaiviet] = @mabaiviet">
        <DeleteParameters>
            <asp:Parameter Name="mabaiviet" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="tenbaiviet" Type="String" />
            <asp:Parameter Name="noidung" Type="String" />
            <asp:Parameter Name="maphumuc" Type="Int32" />
            <asp:Parameter Name="mathanhvien" Type="Int32" />
            <asp:Parameter DbType="Date" Name="ngaylap" />
            <asp:Parameter Name="matinhtrangbv" Type="Int32" />
            <asp:Parameter Name="listchat" Type="String" />
            <asp:Parameter Name="xem" Type="Int32" />
            <asp:Parameter Name="mabaiviet" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="tenbaiviet" Type="String" />
            <asp:Parameter Name="noidung" Type="String" />
            <asp:Parameter Name="maphumuc" Type="Int32" />
            <asp:Parameter Name="mathanhvien" Type="Int32" />
            <asp:Parameter DbType="Date" Name="ngaylap" />
            <asp:Parameter Name="matinhtrangbv" Type="Int32" />
            <asp:Parameter Name="listchat" Type="String" />
            <asp:Parameter Name="xem" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
   
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        SelectCommand="SELECT [maphumuc], [tenphumuc] FROM [PHUMUC]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        SelectCommand="SELECT [mathanhvien], [tenthanhvien] FROM [THANHVIEN]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" 
        SelectCommand="SELECT [matinhtrangbv], [tentinhtrangbv] FROM [TINHTRANGBV]">
    </asp:SqlDataSource>
</asp:Content>

<asp:Content ID="Conten2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

    <uc:Menu ID="menu" runat="server" />
</asp:Content>